﻿var Normal_ClearnCache;
var Normal_ClearnCacheStore;
// 功能模块grid展示
Normal_ClearnCache = function () {

    var url = "/manager/Normal_Lencene/List";

    //grid 填充
    Ext.define('Normal_ClearnCacheGridModel', {
        extend: 'Ext.data.Model',
        fields: [
            { name: "Id", type: "string" },
            { name: "NextText", type: "string" },
            { name: "LastText", type: "string" }
            ]
    });

    //grid获取 json数组
    Normal_ClearnCacheStore = Ext.create('Ext.data.Store', {
        pageSize: 100,
        buffered: false,  //是否动态加载
        model: 'Normal_ClearnCacheGridModel',
        proxy: {
            actionMethods: 'post',
            type: 'ajax',
            url: url,
            reader: {
                type: 'json',
                root: 'root',
                totalProperty: 'totalPorperty'
            }
        }
    });






    ClearnCacheFunciton = function (actionUrl) {

        Ext.MessageBox.show
                                (
                                    {
                                        msg: '正在生成，请稍等...',
                                        progressText: 'Saving...',
                                        width: 300,
                                        wait: true,
                                        waitConfig: { interval: 200 },
                                        icon: 'download',
                                        animEl: 'saving'
                                    }
                                );
        setTimeout(function () { }, 1000);

        Ext.Ajax.timeout = 240000;
        Ext.Ajax.request({
            url: actionUrl,
            method: "get",

            success: function (d) {
                Ext.MessageBox.hide();
                //成功后
                var action = Ext.JSON.decode(d.responseText);
                //alert(action.success);
                var count = action.totalPorperty;
                var message = action.message;
                Normal_ClearnCacheStore.add({ "Id": "", "NextText": action.message });

            },
            failure: function (form, action) {
                Ext.MessageBox.alert("提示!", "修改失败!");
            }
        })
    }
    ClearnCacheFunciton1 = function () {
        ClearnCacheFunciton("/manager/Normal_ClearnCache/ClearnAll");
    }
    ClearnCacheFunciton2 = function () {
        ClearnCacheFunciton("/manager/Normal_ClearnCache/ClearnHTML");
    }
    ClearnCacheFunciton3 = function () {
        ClearnCacheFunciton("/manager/Normal_ClearnCache/ClearnDefaultHTML");
    }
    ClearnCacheFunciton4 = function () {
        ClearnCacheFunciton("/manager/Normal_ClearnCache/ClearnLinkHTML");
    }



    //grid配置
    var grid = Ext.create('Ext.grid.Panel', {
        id: "Normal_ClearnCachePanel",
        renderTo: "Normal_ClearnCacheGrid",
        layout: "fit",
        alias: 'widget.methodPanel',
        columnLines: true,
        loadMask: true,
        frame: true,
        border: false,
        autoScroll: true,
        store: Normal_ClearnCacheStore,
        columnLines: true,
        //cm: cm2,
        viewConfig: {
            stripeRows: true,
            trackOver: true,
            emptyText: '<div style="color:#999;margin:5px;">当前没有记录显示<div>'
        },
        stripeRows: true,
        tbar: [            		 //工具条设置
            		 {
            		 text: "删除所有缓存",
            		 tooltip: "删除所有缓存",
            		 iconCls: "deleteicon",
            		 handler: ClearnCacheFunciton1
           }, "", "-", "", {
               text: "删除所有HTML",
               tooltip: "删除所有HTML",
               iconCls: "deleteicon",
               handler: ClearnCacheFunciton2
           }, "", "-", "", {
               text: "删除首页html",
               tooltip: "删除首页html",
               iconCls: "deleteicon",
               handler: ClearnCacheFunciton3
           }, "", "-", "", {
               text: "删除友情链接缓存",
               tooltip: "删除友情链接缓存",
               iconCls: "deleteicon",
               handler: ClearnCacheFunciton4
           }, "-"],
        columns: [
               Ext.create('Ext.grid.RowNumberer'),
                { header: "编号", dataIndex: "Id", width: 80, sortable: true },
                { header: "提示", dataIndex: "NextText", width: 500, sortable: true }
                  ]
    });


}
    Normal_ClearnCache();
